package com.xltt.vehicleControl.view;

import android.app.Dialog;
import android.content.Context;
import android.graphics.Bitmap;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Button;
import android.widget.TextView;

import androidx.annotation.NonNull;

import com.xltt.vehicleControl.R;

public class LoadingDialog extends Dialog {
    private LoadingDialog(Context context, int themeResId) {
        super(context, themeResId);
    }

    public static class Builder {
        private View mLayout;
        private LoadingDialog mDialog;

        public Builder(Context context) {
            mDialog = new LoadingDialog(context, R.style.dialog_style);
            LayoutInflater inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
            //加载布局文件
            mLayout = inflater.inflate(R.layout.loading_layout, null, false);
            //添加布局文件到 Dialog
            mDialog.addContentView(mLayout, new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,
                             ViewGroup.LayoutParams.WRAP_CONTENT));

         }

          public LoadingDialog create() {
              mDialog.setContentView(mLayout);
              mDialog.setCancelable(true);                //用户可以点击后退键关闭 Dialog
              mDialog.setCanceledOnTouchOutside(false);   //用户不可以点击外部来关闭 Dialog
              return mDialog;
             }
     }
}
